package pers.wq.controller.interceptor;

import java.util.Map;

import pers.wq.controller.BaseIndexAction;

import org.apache.struts2.ServletActionContext;
import org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;


public class LoginInterceptor extends AbstractInterceptor{
	
	@Override
	public String intercept(ActionInvocation arg0) throws Exception {
		// TODO Auto-generated method stub
		Map session = ActionContext.getContext().getSession();
		String key = ((BaseIndexAction)arg0.getAction()).getLoginTag();
		System.out.println(session);
		String value = (String) session.get(key);
		if(value.equals("success")) {
			return arg0.invoke();
		}else {
			return "error";
		}
	}
	
}
